<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>

<script>
    // 有一只羊 第二年生一只羊 第四年生一只羊 第五年死去 问20年后有多少只羊

    var arr = [1,0,0,0,0]

    for (let index = 0; index < 20; index++) {
        const next = arr[1] + arr[3]
        arr.pop()
        arr.unshift(next)
    }
    const sum = arr.reduce((total,cur) => total + cur)

    console.log(sum)
</script>
</html>